var a = getApp();

Page({
    data: {
        active: 0,
        page: 1,
        info: []
    },
    onLoad: function(a) {
        this.getdata();
    },
    onChange: function(a) {
        console.log(a);
        var t = a.detail.index;
        this.setData({
            info: [],
            active: t,
            page: 1,
            current_page: 1,
            last_page: 1
        }), this.getdata();
    },
    goUse: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageH/o2o/storeConsumeIndex/storeConsumeIndex?id=" + t
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) console.log("没有更多"); else {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getdata: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.store-card.Frontend.Modules.Card.Controllers.records.index");
        a._getNetWork({
            url: e,
            data: {
                state: t.data.active,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result ? t.setData({
                    info: e.data.data,
                    current_page: e.data.current_page,
                    last_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.store-card.Frontend.Modules.Card.Controllers.records.index");
        a._postNetWork({
            url: e,
            data: {
                state: t.data.active,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                if (wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result) {
                    var n = e.data.data;
                    t.setData({
                        info: t.data.info.concat(n),
                        current_page: e.data.current_page,
                        last_page: e.data.last_page
                    });
                } else wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});